//C14:14.15:enum.c -- enum value.
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

enum spectrum { red, orange, yellow, green, blue, violet};
const char *colors[] = {"red", "orange", "yellow","green", "blue", "violet"};
#define LEN  30

int main(void)
{
	char choice[LEN];
	enum spectrum color;
	bool color_is_found = false;

	puts("Enter a color (empty line to quit): ");
	while (gets(choice) != NULL && choice[0] != '\0')
	{
		for (color = red; color <= violet; color++)
		{
			
			if(strcmp(choice ,colors[color]) == 0)
			{
				color_is_found = true;
				break;
			}
		}

		if(color_is_found)
		{
			switch(color)
			{
				case red : puts("Roses ared red.");
						   break;
				case orange : puts("Poppies ared orange.");
						      break;
				case yellow : puts("Sumflowers ared yellow.");
							  break;
				case green : puts("Grass ared green.");
							 break;
				case blue : puts("Bluebells ared blue.");
							break;
				case violet : puts("Violets ared violet.");
							  break;
			}	
		}
		else
		{
			printf("I don't know about the color %s.\n", choice);
		}
		color_is_found = false;
		puts("Next color, please (empty line to quit): ");
	}
	puts("Goodbye!\n");
}

